<!doctype html>



  


<html class="theme-next mist use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css"/>




  <link href="//fonts.googleapis.com/css?family=Lato:300,400,700,400italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">



<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=0.5.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="偏好配置,vim," />





  <link rel="alternate" href="/atom.xml" title="Joshua Shaw之秘密花园" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=0.5.0" />






<meta name="description" content="光标移动


操作
含义




h
左移


j
右移


k
上移


l
右移


[Ctrl]+f
上移一页


[Ctrl]+b
下移一页


[Ctrl]+d
上移半页


[Ctrl]+u
下移半页


0, [HOME]
一行的最前页


$, [END]
一行的最后页


H
移动到该页的第一行第一个字符


M
移动到该页的中间行第一个字符


L
移动到该页的最后行第一个字符">
<meta property="og:type" content="article">
<meta property="og:title" content="我的vim">
<meta property="og:url" content="http://joshshaw.github.io/2016/05/12/我的vim/index.html">
<meta property="og:site_name" content="Joshua Shaw之秘密花园">
<meta property="og:description" content="光标移动


操作
含义




h
左移


j
右移


k
上移


l
右移


[Ctrl]+f
上移一页


[Ctrl]+b
下移一页


[Ctrl]+d
上移半页


[Ctrl]+u
下移半页


0, [HOME]
一行的最前页


$, [END]
一行的最后页


H
移动到该页的第一行第一个字符


M
移动到该页的中间行第一个字符


L
移动到该页的最后行第一个字符">
<meta property="og:updated_time" content="2016-05-12T12:25:26.185Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="我的vim">
<meta name="twitter:description" content="光标移动


操作
含义




h
左移


j
右移


k
上移


l
右移


[Ctrl]+f
上移一页


[Ctrl]+b
下移一页


[Ctrl]+d
上移半页


[Ctrl]+u
下移半页


0, [HOME]
一行的最前页


$, [END]
一行的最后页


H
移动到该页的第一行第一个字符


M
移动到该页的中间行第一个字符


L
移动到该页的最后行第一个字符">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Mist',
    sidebar: {"position":"left","display":"always"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 0,
      author: '博主'
    }
  };
</script>

  <title> 我的vim | Joshua Shaw之秘密花园 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  



  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?99d95abecc387f2aa83d123804dddd4c";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>








  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">Joshua Shaw之秘密花园</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">成就自己</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-home fa-fw"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-user fa-fw"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-th fa-fw"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-archive fa-fw"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-tags fa-fw"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                我的vim
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-05-12T17:11:43+08:00" content="2016-05-12">
              2016-05-12
            </time>
          </span>

          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2016/05/12/我的vim/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/05/12/我的vim/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="光标移动"><a href="#光标移动" class="headerlink" title="光标移动"></a>光标移动</h1><table>
<thead>
<tr>
<th style="text-align:center">操作</th>
<th style="text-align:left">含义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">h</td>
<td style="text-align:left">左移</td>
</tr>
<tr>
<td style="text-align:center">j</td>
<td style="text-align:left">右移</td>
</tr>
<tr>
<td style="text-align:center">k</td>
<td style="text-align:left">上移</td>
</tr>
<tr>
<td style="text-align:center">l</td>
<td style="text-align:left">右移</td>
</tr>
<tr>
<td style="text-align:center">[Ctrl]+f</td>
<td style="text-align:left">上移一页</td>
</tr>
<tr>
<td style="text-align:center">[Ctrl]+b</td>
<td style="text-align:left">下移一页</td>
</tr>
<tr>
<td style="text-align:center">[Ctrl]+d</td>
<td style="text-align:left">上移半页</td>
</tr>
<tr>
<td style="text-align:center">[Ctrl]+u</td>
<td style="text-align:left">下移半页</td>
</tr>
<tr>
<td style="text-align:center">0, [HOME]</td>
<td style="text-align:left">一行的最前页</td>
</tr>
<tr>
<td style="text-align:center">$, [END]</td>
<td style="text-align:left">一行的最后页</td>
</tr>
<tr>
<td style="text-align:center">H</td>
<td style="text-align:left">移动到该页的第一行第一个字符</td>
</tr>
<tr>
<td style="text-align:center">M</td>
<td style="text-align:left">移动到该页的中间行第一个字符</td>
</tr>
<tr>
<td style="text-align:center">L</td>
<td style="text-align:left">移动到该页的最后行第一个字符</td>
</tr>
<tr>
<td style="text-align:center">G</td>
<td style="text-align:left">移动到文件最后一行</td>
</tr>
<tr>
<td style="text-align:center">nG</td>
<td style="text-align:left">移动到第n行（1G移动到文件头）</td>
</tr>
<tr>
<td style="text-align:center">gg</td>
<td style="text-align:left">等同1G</td>
</tr>
<tr>
<td style="text-align:center">n[Enter]</td>
<td style="text-align:left">光标向下移动n行</td>
</tr>
</tbody>
</table>
<a id="more"></a>
<h1 id="字符串的查找与替换"><a href="#字符串的查找与替换" class="headerlink" title="字符串的查找与替换"></a>字符串的查找与替换</h1><table>
<thead>
<tr>
<th style="text-align:center">操作</th>
<th style="text-align:left">含义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">/word</td>
<td style="text-align:left">向下寻找word字符串（?word为向上）</td>
</tr>
<tr>
<td style="text-align:center">n</td>
<td style="text-align:left">重复前一个操作</td>
</tr>
<tr>
<td style="text-align:center">N</td>
<td style="text-align:left">反方向重复前一个操作</td>
</tr>
<tr>
<td style="text-align:center">:n1, n2s/word1/word2/g(c)</td>
<td style="text-align:left">从第n1行到第n2行查找word1并换成word2，+c的话需要用户确认每次替换</td>
</tr>
<tr>
<td style="text-align:center">1, $</td>
<td style="text-align:left">上一行的n1和n2，全文的查找和替换</td>
</tr>
</tbody>
</table>
<h1 id="复制、撤销、重复"><a href="#复制、撤销、重复" class="headerlink" title="复制、撤销、重复"></a>复制、撤销、重复</h1><table>
<thead>
<tr>
<th style="text-align:center">操作</th>
<th style="text-align:left">含义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">v</td>
<td style="text-align:left">光标选定模式，配合上下左右选定段，再按y复制，或按d删除</td>
</tr>
<tr>
<td style="text-align:center">[Ctrl]+v</td>
<td style="text-align:left">快选择，可以用长方形的方式选择数据</td>
</tr>
<tr>
<td style="text-align:center">yy</td>
<td style="text-align:left">复制当前行</td>
</tr>
<tr>
<td style="text-align:center">p, P</td>
<td style="text-align:left">将已经复制的数据在光标下一行粘贴，大写P为上一行</td>
</tr>
<tr>
<td style="text-align:center">u</td>
<td style="text-align:left">复原前一操作</td>
</tr>
<tr>
<td style="text-align:center">[Ctrl]+r</td>
<td style="text-align:left">重做上一操作</td>
</tr>
<tr>
<td style="text-align:center">nyy</td>
<td style="text-align:left">复制光标（包括光标行）向下n行</td>
</tr>
</tbody>
</table>
<h1 id="我的-vimrc配置"><a href="#我的-vimrc配置" class="headerlink" title="我的.vimrc配置"></a>我的<code>.vimrc</code>配置</h1><figure class="highlight vim"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">set</span> <span class="keyword">number</span>           <span class="comment">"显示行号</span></span><br><span class="line"><span class="keyword">set</span> nowrap           <span class="comment">"不换行</span></span><br><span class="line"><span class="keyword">set</span> <span class="built_in">shiftwidth</span>=<span class="number">4</span>     <span class="comment">"默认缩进4个空格</span></span><br><span class="line"><span class="keyword">set</span> softtabstop=<span class="number">4</span>    <span class="comment">"使用tab时 tab空格数</span></span><br><span class="line"><span class="keyword">set</span> tabstop=<span class="number">4</span>        <span class="comment">"tab代表4个空格</span></span><br><span class="line"><span class="keyword">set</span> laststatus=<span class="number">2</span>     <span class="comment">"总是显示状态行</span></span><br><span class="line"></span><br><span class="line">                     <span class="comment">" indent 删除自动缩进的值</span></span><br><span class="line">                     <span class="comment">" eol 删除上一行行末尾的回车，两行合并</span></span><br><span class="line">                     <span class="comment">" start 除了刚输入的，还删除原来的字符</span></span><br><span class="line"><span class="keyword">set</span> backspace=<span class="built_in">indent</span>,eol,start</span><br><span class="line"></span><br><span class="line"><span class="keyword">set</span> expandtab       <span class="comment">"使用空格替换tab</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">set</span> autoindent      <span class="comment">" 自动缩进</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">colorscheme</span> evening <span class="comment">"颜色模式</span></span><br><span class="line"></span><br><span class="line">syn <span class="keyword">on</span>              <span class="comment">"语法高亮</span></span><br><span class="line"><span class="keyword">filetype</span> <span class="keyword">on</span>         <span class="comment">"文件类型</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">set</span> encoding=utf-<span class="number">8</span>  <span class="comment">"编码为utf8</span></span><br></pre></td></tr></table></figure>

      
    </div>

    <div>
      
        
      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/偏好配置/" rel="tag">#偏好配置</a>
          
            <a href="/tags/vim/" rel="tag">#vim</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/05/09/RAID/" rel="next" title="RAID">
                <i class="fa fa-chevron-left"></i> RAID
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2016/05/17/How-to-be-drunbility-zhuangbility/" rel="prev" title="How to be drunbility(zhuangbility)?">
                How to be drunbility(zhuangbility)? <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <!-- JiaThis Button BEGIN -->
<div class="jiathis_style">
  <a class="jiathis_button_tsina"></a>
  <a class="jiathis_button_tqq"></a>
  <a class="jiathis_button_weixin"></a>
  <a class="jiathis_button_cqq"></a>
  <a class="jiathis_button_douban"></a>
  <a class="jiathis_button_renren"></a>
  <a class="jiathis_button_qzone"></a>
  <a class="jiathis_button_kaixin001"></a>
  <a class="jiathis_button_copy"></a>
  <a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank"></a>
  <a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript" >
  var jiathis_config={
    hideMore:false
  }
</script>
<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END -->

      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2016/05/12/我的vim/"
           data-title="我的vim" data-url="http://joshshaw.github.io/2016/05/12/我的vim/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.png"
               alt="Joshua Shaw" />
          <p class="site-author-name" itemprop="name">Joshua Shaw</p>
          <p class="site-description motion-element" itemprop="description"></p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">20</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">6</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">26</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/joshuashawnetlab" target="_blank">
                  
                    <i class="fa fa-globe"></i> Github_1
                  
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://github.com/joshshaw" target="_blank">
                  
                    <i class="fa fa-globe"></i> Github_2
                  
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://weibo.com/u/2622463195" target="_blank">
                  
                    <i class="fa fa-weibo"></i> Weibo
                  
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://my.oschina.net/joshuashaw" target="_blank">
                  
                    <i class="fa fa-globe"></i> OSChina
                  
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://www.zhihu.com/people/xiao-chong-chong-41" target="_blank">
                  
                    <i class="fa fa-globe"></i> Zhihu
                  
                </a>
              </span>
            
          
        </div>

        
        

        
        <div class="links-of-blogroll motion-element">
          
        </div>

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc-indicator-top post-toc-indicator">
            <i class="fa fa-angle-double-up"></i>
          </div>
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#光标移动"><span class="nav-number">1.</span> <span class="nav-text">光标移动</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#字符串的查找与替换"><span class="nav-number">2.</span> <span class="nav-text">字符串的查找与替换</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#复制、撤销、重复"><span class="nav-number">3.</span> <span class="nav-text">复制、撤销、重复</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#我的-vimrc配置"><span class="nav-number">4.</span> <span class="nav-text">我的.vimrc配置</span></a></li></ol></div>
            
          </div>
          <div class="post-toc-indicator-bottom post-toc-indicator">
            <i class="fa fa-angle-double-down"></i>
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2015 - 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Joshua Shaw</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="http://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>



      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  


  




<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  <script type="text/javascript" src="/vendors/velocity/velocity.min.js"></script>

  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js"></script>

  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=0.5.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=0.5.0"></script>



  
  

  
  
<script type="text/javascript" src="/js/src/scrollspy.js?v=0.5.0"></script>

<script type="text/javascript" id="sidebar.toc.highlight">
  $(document).ready(function () {
    var tocSelector = '.post-toc';
    var $tocSelector = $(tocSelector);
    var activeCurrentSelector = '.active-current';

    $tocSelector
      .on('activate.bs.scrollspy', function () {
        var $currentActiveElement = $(tocSelector + ' .active').last();

        removeCurrentActiveClass();
        $currentActiveElement.addClass('active-current');

        $tocSelector[0].scrollTop = $currentActiveElement.position().top;
      })
      .on('clear.bs.scrollspy', function () {
        removeCurrentActiveClass();
      });

    function removeCurrentActiveClass () {
      $(tocSelector + ' ' + activeCurrentSelector)
        .removeClass(activeCurrentSelector.substring(1));
    }

    function processTOC () {
      getTOCMaxHeight();
      toggleTOCOverflowIndicators();
    }

    function getTOCMaxHeight () {
      var height = $('.sidebar').height() -
                   $tocSelector.position().top -
                   $('.post-toc-indicator-bottom').height();

      $tocSelector.css('height', height);

      return height;
    }

    function toggleTOCOverflowIndicators () {
      tocOverflowIndicator(
        '.post-toc-indicator-top',
        $tocSelector.scrollTop() > 0 ? 'show' : 'hide'
      );

      tocOverflowIndicator(
        '.post-toc-indicator-bottom',
        $tocSelector.scrollTop() >= $tocSelector.find('ol').height() - $tocSelector.height() ? 'hide' : 'show'
      )
    }

    $(document).on('sidebar.motion.complete', function () {
      processTOC();
    });

    $('body').scrollspy({ target: tocSelector });
    $(window).on('resize', function () {
      if ( $('.sidebar').hasClass('sidebar-active') ) {
        processTOC();
      }
    });

    onScroll($tocSelector);

    function onScroll (element) {
      element.on('mousewheel DOMMouseScroll', function (event) {
          var oe = event.originalEvent;
          var delta = oe.wheelDelta || -oe.detail;

          this.scrollTop += ( delta < 0 ? 1 : -1 ) * 30;
          event.preventDefault();

          toggleTOCOverflowIndicators();
      });
    }

    function tocOverflowIndicator (indicator, action) {
      var $indicator = $(indicator);
      var opacity = action === 'show' ? 1 : 0;
      $indicator.velocity ?
        $indicator.velocity('stop').velocity({
          opacity: opacity
        }, { duration: 100 }) :
        $indicator.stop().animate({
          opacity: opacity
        }, 100);
    }

  });
</script>

<script type="text/javascript" id="sidebar.nav">
  $(document).ready(function () {
    var html = $('html');
    var TAB_ANIMATE_DURATION = 200;
    var hasVelocity = $.isFunction(html.velocity);

    $('.sidebar-nav li').on('click', function () {
      var item = $(this);
      var activeTabClassName = 'sidebar-nav-active';
      var activePanelClassName = 'sidebar-panel-active';
      if (item.hasClass(activeTabClassName)) {
        return;
      }

      var currentTarget = $('.' + activePanelClassName);
      var target = $('.' + item.data('target'));

      hasVelocity ?
        currentTarget.velocity('transition.slideUpOut', TAB_ANIMATE_DURATION, function () {
          target
            .velocity('stop')
            .velocity('transition.slideDownIn', TAB_ANIMATE_DURATION)
            .addClass(activePanelClassName);
        }) :
        currentTarget.animate({ opacity: 0 }, TAB_ANIMATE_DURATION, function () {
          currentTarget.hide();
          target
            .stop()
            .css({'opacity': 0, 'display': 'block'})
            .animate({ opacity: 1 }, TAB_ANIMATE_DURATION, function () {
              currentTarget.removeClass(activePanelClassName);
              target.addClass(activePanelClassName);
            });
        });

      item.siblings().removeClass(activeTabClassName);
      item.addClass(activeTabClassName);
    });

    $('.post-toc a').on('click', function (e) {
      e.preventDefault();
      var targetSelector = NexT.utils.escapeSelector(this.getAttribute('href'));
      var offset = $(targetSelector).offset().top;
      hasVelocity ?
        html.velocity('stop').velocity('scroll', {
          offset: offset  + 'px',
          mobileHA: false
        }) :
        $('html, body').stop().animate({
          scrollTop: offset
        }, 500);
    });

    // Expand sidebar on post detail page by default, when post has a toc.
    NexT.motion.middleWares.sidebar = function () {
      var $tocContent = $('.post-toc-content');

      if (CONFIG.sidebar.display === 'post' || CONFIG.sidebar.display === 'always') {
        if ($tocContent.length > 0 && $tocContent.html().trim().length > 0) {
          NexT.utils.displaySidebar();
        }
      }
    };
  });
</script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=0.5.0"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"joshuashaw"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
  





  
  
  

  


</body>
</html>
